<template>
	<view class="main">
		<view class="cell-sq-home" v-for="(item,index) in waitList" :key="index">
			<image class="severImg" :src="$IMG_URL+'/static/images/BIG-my/sqsever.png'" mode=""></image>
			<text class="cell-sq-title">{{item.fuser.nickname}}</text>
			<text class="cell-sq-content">申请与您成为家属</text>
			<view class="cell-sq-btnBox">
				<view class="sq-ok" @click="editSQ(item.id,true)">同意</view>
				<view class="sq-no" @click="editSQ(item.id,false)">拒绝</view>
			</view>
		</view>
		<view class="cell-row-item" v-for="(it,index) in hasList" :key="index">
			<view class="left-icon">
				<image :src="it.user.avatar" mode=""></image>
			</view>
			<view class="min-content">
				<view class="con-top">
					<text class="row-user">{{it.name}}</text>
					<text class="sf-row">家属</text>
					<text class="row-state">{{it.status==0?'等待绑定':it.status==2?'已被拒绝':''}}</text>
				</view>
				<view class="user-phone">{{it.user.mobile}}</view>
			</view>
			<view class="row-edit" @click="toEdit(it.name,it.id,it.user.mobile)">
				编辑
			</view>
		</view>
		<view class="btom-btn">
			<text @click="toAddHome">添加家属</text>
		</view>
	</view>
</template>

<script>
	import http from '@/shopro/request/index'
import { init } from '../../shopro';
	export default {
		data() {
			return {
				waitList:[],
				hasList:[]
			};
		},
		onShow() {
			this.init()
		},
		// onLoad() {
			
		// },
		methods :{
			init(){
				http('user.homeList').then(res=>{
					console.log(res);
					this.waitList = res.data.auditList
					this.hasList = res.data.userFamilyList
					// this.waitList = res.data.filter(it=>{
					// 	if(it.status==0){
					// 		return it
					// 	}
					// })
					// this.hasList = res.data.filter(it=>{
					// 	if(it.status==1){
					// 		return it
					// 	}
					// })
					console.log(this.waitList,this.hasList);
				})
			},
			toAddHome(){
				uni.navigateTo({
					url:'./addHomePhone'
				})
			},
			toEdit (name,id,phone){
				uni.navigateTo({
					url:'./editHomePhone?id='+id+'&name='+name+'&phone='+phone
				})
			},
			editSQ(id,flag){
				http('user.editSQ',{
					status:flag==true?'1':'2',
					id:id.toString()
				}).then(res=>{
					console.log(res);
					if(res.code==1){
						if(flag==true){
							uni.showToast({
								title: '已同意申请'
							});
						} else {
							uni.showToast({
								title:'已拒绝申请'
							})
						}
						
						this.init()
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.main {
		padding-top: 8px;
		padding-bottom: 69px;
		.cell-sq-home {
			margin-bottom: 8px;
			margin-left:10px ;
			margin-right: 10px;
			position: relative;
			padding: 20px 24px;
			box-sizing: border-box;
			color: #000;
			overflow: hidden;
			border-radius: 10px;
			background-image: linear-gradient(0deg, 
					rgba(255, 255, 255, 0.25) 0%, 
					rgba(255, 136, 48, 0.25) 100%), 
				linear-gradient(
					#ffffff, 
					#ffffff);
				background-blend-mode: normal, 
					normal;
					.severImg {
						position: absolute;
						width: 53px;
							height: 48px;
							// opacity: 0.24;
							right:44px ;
							top: 20px;
					}
			.cell-sq-title {
				font-size: 20px;
				display: block;
			}
			.cell-sq-content {
				display: block;
				font-size: 16px;
				margin: 10px 0 16px;
			}
			.cell-sq-btnBox {
				display: flex;
				.sq-ok {
					flex: 1;
					height: 36px;
						background-image: linear-gradient(90deg, 
							#ff8300 0%, 
							#ff3d00 100%), 
						linear-gradient(
							#ff3f00, 
							#ff3f00);
						background-blend-mode: normal, 
							normal;
						border-radius: 18px;
						line-height: 36px;
						text-align: center;
						font-size: 18px;
						color: #ffffff;
				}
				.sq-no {
					flex: 1;
					margin-left: 15px;
					height: 36px;
						border-radius: 18px;
						border: solid 1px #ff3400;
						line-height: 36px;
						text-align: center;
						color: #ff3e00;
						font-size: 18px;
				}
			}
		}
	}
	.cell-row-item {
		background-color: #ffffff;
		padding: 22px 13px 19px;
		display: flex;
		align-items: center;
		margin-bottom: 8px;
		.left-icon {
			border-radius: 50%;
			overflow: hidden;
			background-color: #fff4f1;
			width: 50px;
			height: 50px;
			display: flex;
			align-items: center;
			justify-content: center;
			image {
				width: 100%;
					height: 100%;
			}
		}
		.min-content {
			flex: 1;
			margin-left: 15px;
			.con-top {
				display: flex;
				align-items: center;
				margin-bottom: 8px;
				.row-user {
					font-size: 20px;
					color: #000000;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
				.sf-row {
					white-space: nowrap;
					font-size: 12px;
					color: #ff3400;
					background-color: #fff4f1;
					border-radius: 2px;
					margin: 0 15px 0 8px;
					padding: 3px 7px;
				}
				.row-state {
					white-space: nowrap;
					font-size: 15px;
					color: #ff8300;
				}
			}
			.user-phone {
				font-size: 16px;
				color: #999;
			}
		}
		.row-edit {
			white-space: nowrap;
			font-size: 18px;
			color: #ff3400;
		}
	}
	.btom-btn {
		background-color: #fff;
		border-top: 1px solid #e5e5e5;
		padding: 14px 10px;
		box-sizing: border-box;
		position: fixed;
		width: 100%;
		bottom: 0;
		text {
			display: block;
			font-size: 20px;
				font-weight: bold;
				color: #fff;
				height: 40px;
					background-image: linear-gradient(90deg, 
						#ff8300 0%, 
						#ff3d00 100%), 
					linear-gradient(
						#ffffff, 
						#ffffff);
					background-blend-mode: normal, 
						normal;
					border-radius: 20px;
					line-height: 40px;
					text-align: center;
		}
	
	}
</style>
